package com.lib76.buildCode.dao;

import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import com.lib76.buildCode.model.Project;

/**
 * 项目数据访问
 * @author 张浩
 *
 */
public class ProjectDao {

	final static ConcurrentMap<String,Project> STORE = new ConcurrentHashMap<String,Project>();
	
	/**
	 * 添加一个项目
	 * @param project
	 */
	public static void save(Project project){
		STORE.put(project.getProjectCode(), project);
	}
	
	/**
	 * 根据项目代码查找项目信息
	 * @param code
	 * @return
	 */
	public static Project findByCode(String code){
		return STORE.get(code);
	}
	
	/**
	 * 获取所有项目
	 * @return
	 */
	public static Collection<Project> findAll(){
		return STORE.values();
	}
}
